package pojo;

import anna.ExcelConfig;
import anna.ExcelField;

import java.io.Serializable;
import java.util.Optional;

@ExcelConfig
public class RequestDetailPoJo implements Serializable {
    /**
     * 接口编号
     */
    @ExcelField(index = 0,value = "接口编号")
    private String serviceCode;
    /**
     * 接口描述
     */
    @ExcelField(index = 1,value = "接口描述")
    private String serviceDesc;
    /**
     * 请求地址
     */
    @ExcelField(index = 2,value = "请求地址")
    private String url;
    /**
     * 请求参数
     */
    @ExcelField(index = 3,value = "请求参数")
    private String request;
    /**
     * 请求结果
     */
    @ExcelField(index = 4,value = "请求结果")
    private String result;
    /**
     * 耗时
     */
    @ExcelField(index = 5,value = "耗时")
    private Long time;
    /**
     * 请求结果类型(SUCCESS,FAIL,ERROR)
     */
    @ExcelField(index = 6,value = "请求结果类型")
    private String resultType;
    /**
     * 错误码
     */
    @ExcelField(index = 7,value = "错误码")
    private String errorCode;

    /**
     * 是否执行了对比
     */
    @ExcelField(index = 8,value = "对比")
    private String compa;
    /**
     * 是否执行了对比
     */
    @ExcelField(index = 9,value = "是否一致")
    private String compaPass;
    /**
     * 对比结果类型
     */
    @ExcelField(index = 10,value = "对比结果类型")
    private String compaResultType;
    /**
     * 对比地址
     */
    @ExcelField(index = 11,value = "对比地址")
    private String compaUrl;
    /**
     * 对比结果
     */
    @ExcelField(index = 12,value = "对比结果")
    private String compaResult;
    /**
     * 对比耗时
     */
    @ExcelField(index = 13,value = "对比耗时")
    private Long compaTime;

    /**
     * 再次运行是否过滤
     */
    @ExcelField(index = 14,value = "再次运行是否过滤")
    private String filter;

    public RequestDetailPoJo() {
    }

    public static RequestDetailPoJo build(ServiceDesc desc, PostResult postResult) {
        RequestDetailPoJo requestDetailPoJo = new RequestDetailPoJo();

        requestDetailPoJo.setServiceCode(desc.getServiceCode());
        requestDetailPoJo.setServiceDesc(desc.getServiceDesc());
        requestDetailPoJo.setUrl(postResult.getUrl());
        requestDetailPoJo.setRequest(postResult.getRequest());
        requestDetailPoJo.setResult(postResult.getResult());
        requestDetailPoJo.setResultType(postResult.getResultType());
        requestDetailPoJo.setErrorCode(postResult.getErrorCode());
        requestDetailPoJo.setTime(postResult.getTime());

        return requestDetailPoJo;
    }

    public String getServiceCode() {
        serviceCode = Optional.ofNullable(serviceCode).orElse("");
        return serviceCode;
    }

    public void setServiceCode(String serviceCode) {
        this.serviceCode = serviceCode;
    }

    public String getServiceDesc() {
        serviceDesc = Optional.ofNullable(serviceDesc).orElse("");
        return serviceDesc;
    }

    public void setServiceDesc(String serviceDesc) {
        this.serviceDesc = serviceDesc;
    }

    public String getUrl() {
        url = Optional.ofNullable(url).orElse("");
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getRequest() {
        request = Optional.ofNullable(request).orElse("");
        return request;
    }

    public void setRequest(String request) {
        this.request = request;
    }

    public String getResult() {
        result = Optional.ofNullable(result).orElse("");
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public Long getTime() {
        return time;
    }

    public void setTime(Long time) {
        this.time = time;
    }

    public String getResultType() {
        resultType = Optional.ofNullable(resultType).orElse("");
        return resultType;
    }

    public void setResultType(String resultType) {
        this.resultType = resultType;
    }

    public String getErrorCode() {
        errorCode = Optional.ofNullable(errorCode).orElse("");
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getFilter() {
        filter = Optional.ofNullable(filter).orElse("");
        return filter;
    }

    public void setFilter(String filter) {
        this.filter = filter;
    }

    public String getCompa() {
        compa = Optional.ofNullable(compa).orElse("");
        return compa;
    }

    public void setCompa(String compa) {
        this.compa = compa;
    }

    public String getCompaResultType() {
        compaResultType = Optional.ofNullable(compaResultType).orElse("");
        return compaResultType;
    }

    public void setCompaResultType(String compaResultType) {
        this.compaResultType = compaResultType;
    }

    public String getCompaUrl() {
        compaUrl = Optional.ofNullable(compaUrl).orElse("");
        return compaUrl;
    }

    public void setCompaUrl(String compaUrl) {
        this.compaUrl = compaUrl;
    }

    public String getCompaResult() {
        compaResult = Optional.ofNullable(compaResult).orElse("");
        return compaResult;
    }

    public void setCompaResult(String compaResult) {
        this.compaResult = compaResult;
    }

    public Long getCompaTime() {
        compaTime = Optional.ofNullable(compaTime).orElse(0L);
        return compaTime;
    }

    public void setCompaTime(Long compaTime) {
        this.compaTime = compaTime;
    }

    public String getCompaPass() {
        compaPass = Optional.ofNullable(compaPass).orElse("");
        return compaPass;
    }

    public void setCompaPass(String compaPass) {
        this.compaPass = compaPass;
    }
}
